<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>修改快递信息</span>
			</div>
			<div class="content">
				<table>	
					<tr>
						<td class="text-right">运单号</td><td class="content_right">
						<input class="input inline-input" placeholder="请输入运单号码" id="number">
						<span class="btn btn-info" id="find" style="cursor: pointer;">立即查找</span></td>
					</tr>
				</table>
			</div>
			
			
			<div class="header">
				<span>查找信息如下</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">快递单号</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">快递公司</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">收货人姓名</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">快递状态</td>
							<td class="content_right">
								<input type="radio" class="status" name="status" value="1">待付款
								<input class="status"  name="status" type="radio" value="2">待派送
								<input type="radio" class="status" name="status" value="3">已派送
								<input class="status"  name="status" type="radio" value="4">已完成
								<input type="radio" class="status" name="status" value="5">已取消
							</td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span class="btn btn-info" id="update">立即修改</span>
					</tr>
				</table>
			</div>
		</div>
	</body>
	<script src="../../../qrcode/jquery2.1.4.js"></script>
	<script src="../../../layer/layer.js"></script>
<script>
	// $(".header:eq(1),.content:eq(1)").hide();
	// var expressId = null;
	// var g_userPhone = null;
	$(function(){
		$(".header:eq(1),.content:eq(1)").hide();
		var expressId = null;
		var g_userPhone = null;
		//查找
		$("#find").click(function() {
			var windowId = layer.load();
			var number = $("#number").val();
			$.getJSON("/express/find.do", {number: number}, function (data) {
				layer.close(windowId);
				//data:{"status":0,"result":"查询成功","data":{"id":2,"number":"124","username":"张三","userPhone":"13843838438","company":"京东快递","code":"213456","inTime":"Jul 21, 2020, 4:26:21 PM","status":0,"sysPhone":"18888888888"}}
				layer.msg("查询中......");
				if (data.status === 1) {
					layer.msg("查询成功");
					$(".header:eq(1),.content:eq(1)").fadeIn(1000);
					expressId = data.data.id;
					g_userPhone = data.data.phone;
					$("input:eq(1)").val(data.data.number);
					$("input:eq(2)").val(data.data.companyName);
					$("input:eq(3)").val(data.data.name);
					$("input:eq(4)").val(data.data.phone);
					// $(".status:eq(data.data.status-1)").prop("checked",true);
					if (data.data.status == 1) {
						$(".status:eq(0)").prop("checked", true);
					} else if (data.data.status == 2) {
						$(".status:eq(1)").prop("checked", true);
					} else if (data.data.status == 3) {
						$(".status:eq(2)").prop("checked", true);
					} else if (data.data.status == 4) {
						$(".status:eq(3)").prop("checked", true);
					} else if (data.data.status == 5) {
						$(".status:eq(4)").prop("checked", true);
					}
					// if(data.data.status == 0){
					// 	//未签收
					// 	$(".status:eq(1)").prop("checked",true);
					// }else{
					// 	//已签收
					// 	$(".status:eq(0)").prop("checked",true);
					// }
				}else {
					layer.msg("未找到，请重新输入");
				}
			})
		});

			//修改
		$("#update").click(function(){
			var windowId = layer.load();
			var number = $("input:eq(1)").val();
			var companyName = $("input:eq(2)").val();
			var name = $("input:eq(3)").val();
			var phone = $("input:eq(4)").val();

			var status = $(".status:checked").val();
			var express = {
				id:expressId,
				number:number,
				companyName:companyName,
				name:name,
				status:status
			};
			if(phone != g_userPhone){
				express.phone = phone;
			}
			//修改
			$.ajax({
				type: 'POST',
				url: "/express/update.do",
				dataType: 'json',
				cache: false,
				headers : {
					'Content-Type' : 'application/json;charset=utf-8'
				},
				data: JSON.stringify(express),
				success: function(data){
					if(data==='success'){
						layer.msg("信息更改成功",{time:1000});
						// layer.closeAll(); //疯狂模式，关闭所有层
						layer.close(windowId);
						// layer.close();
						// location.reload();
					}else{
						layer.msg("信息更改失败",{icon:1,time:1000});
						// location.reload();
					}
				}
			});
			// layer.close(load);
			layer.closeAll(); //疯狂模式，关闭所有层
		});


	});
</script>
</html>
